﻿@model BLL.Model.User.UserInfo
@{
    Layout = null;
    Model.IsAdmin = Model.RoleList[0].Name == "admin";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    function closeDialog() {
        $("#editDiv").data("dialog").close();
    }

    function getData() {
        return $("form:first").serialize();
    }

    $().ready(function () {
        $(":submit").button().click(function () {
            var form = $("form:first");
            if (form.valid()) {
                var data = getData();
                $.post("/user/edit", data, function (result) {
                    if (result === "ok") {
                        alert("更新成功！");
                        closeDialog();
                    }
                    else {
                        alert(result);
                    }
                });
            }
            return false;
        });
    });
</script>
@using (Html.BeginForm("Edit", "User"))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>用户信息</legend>
        @Html.HiddenFor(model => model.Id)
        @*AccountName*@
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 2px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-15" style="margin: 2px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.AccountName)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Model.AccountName
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @*UserName*@
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 2px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-15" style="margin: 2px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.UserName)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.UserName, new { @class = "search_input" })
                            <em>
                                @Html.ValidationMessageFor(model => model.UserName)
                            </em>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @*Email*@
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 2px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-15" style="margin: 2px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.Email)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.Email, new { @class = "search_input" })
                            <em>
                                @Html.ValidationMessageFor(model => model.Email)
                            </em>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @*Phone*@
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 2px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-15" style="margin: 2px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.Phone)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.Phone, new { @class = "search_input" })
                            <em>
                                @Html.ValidationMessageFor(model => model.Phone)
                            </em>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @*Admin*@
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 2px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-15" style="margin: 2px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.IsAdmin)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.CheckBoxFor(model => model.IsAdmin)
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <p>
            <input type="submit" value="保  存" />
        </p>
    </fieldset>
}
